Ubuntu Text Processing: Using the cat Command to View File Contents

The `cat` command is a fundamental text processing tool in the Ubuntu system, derived from "concatenate". Its core function is to view and merge file contents. The basic syntax `cat filename` can display a file's content (e.g., viewing `test.txt`). Common options enhance its functionality: `-n` shows line numbers for all lines (including empty ones), `-b` only numbers non-empty lines, and `-s` merges consecutive empty lines. For multi-file processing, you can view multiple files simultaneously (e.g., `cat file1 file2`) or redirect the merged output to a new file using `>` (e.g., `cat a.txt b.txt > new.txt`). Important notes: If the file does not exist, an error will occur, so verify the path. If permissions are insufficient, use `sudo`. The `>` redirection overwrites the target file; it is recommended to back up or use `>>` for appending instead. Despite its simplicity, `cat` is highly practical. By practicing basic operations (e.g., testing different options and merging multiple files), you can quickly master its flexible applications.

Read More
Quick Start: Creating Folders with Ubuntu mkdir

This article introduces the basic command `mkdir` for creating directories in the Ubuntu system. Short for "make directory", `mkdir` is used to create empty directories and is an essential tool for organizing files. **Basic usage**: To create a single folder in the current directory, use the command format `mkdir 文件夹名称` (e.g., `mkdir projects`). For creating directories at a specified path (relative or absolute), directly specify the path: e.g., `mkdir ~/Documents/notes` or `mkdir /tmp/temp_files`. To create nested directories (e.g., `a/b/c`), the regular `mkdir` will fail if parent directories do not exist. In this case, use the `-p` option (`--parents`) to automatically create all parent directories (e.g., `mkdir -p workspace/code/python`). **Common issues**: Use `-p` when parent directories do not exist; if permission is insufficient, use `sudo` (with caution). **Summary**: The core syntax of `mkdir` is `mkdir [options] path`. It creates single directories by default, requires `-p` for nested directories, and uses `sudo` for permission issues.

Read More
Linux Server Basics: From Installation to Network Configuration

This article introduces the basics of Linux servers, covering core steps and key skills. Linux servers, based on open - source systems, are suitable for stable service scenarios (such as those adopted by Alibaba Cloud). For beginners, it is recommended to use Ubuntu Server (user - friendly for novices), CentOS Stream (enterprise - level), and Debian (for basic learning). When installing, virtual machines (VMware/VirtualBox) are preferred, and ISO images and resources of 2 cores, 4G memory, and 40G storage are required. Taking Ubuntu as an example, during virtual machine installation, a username and password need to be set, and automatic partitioning should be used. The core of the system is the command - line interface. Basic commands such as `ls` (list files), `cd` (change directory), and `sudo` (elevate privileges) are commonly used. For network configuration, a static IP needs to be set (CentOS modifies the network card file, while Ubuntu uses Netplan), and ports 80 and 22 should be opened. After installing the SSH service (sshd for CentOS and ssh for Ubuntu), remote connections can be made using Xshell on Windows, or directly via the `ssh` command on Linux/macOS. Key steps include: choosing a distribution → installing in a virtual machine → basic commands → network configuration → SSH connection. Beginners are advised to further study permission management, deploying services such as Nginx, and system monitoring tools. For issues, they can refer to the `man` manual or official documentation.

Read More